<!DOCTYPE html>
<html>
<script src="../../resources/js-test.js"></script>
<div id="a"></div>
<div id="b"><iframe id="f"></iframe></div>
<script>
description("Allow nested frame detaches from subframe without crashing.");

self.jsTestIsAsync = true;
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var iframe = f.contentDocument;
iframe.open();
function moveDivBIntoDivA() {
    try {
        a.appendChild(b);
        iframe.open();
    } catch(e) {
        finishJSTest();
    }
}

iframe.addEventListener('readystatechange', moveDivBIntoDivA);
moveDivBIntoDivA();
</script>
</html>
